Skip to content

feat(kr-activation): bitemporal as-of route + durable tool-observation memory - #98

Merged
RecursiveIntell merged 1 commit into
mainfrom
feat/kr-activation-main-20261125
Nov 25, 2026
Merged

RecursiveIntell merged 1 commit into
mainfrom
feat/kr-activation-main-20261125

Conversation

@RecursiveIntell

Copy link
Copy Markdown
Owner

Adds: (A) bitemporal as-of bridge + temporal-route consumption via KnowledgeRuntime::with_bitemporal_records; (B) durable ToolObservationMemory impl for MemoryStore + activated previously-orphaned semantic_memory module; tests for both. Cherry-picked onto main from the remediation line. Local: fmt clean, clippy -D warnings clean on touched crates, all touched-crate tests pass (knowledge-runtime 60+51+... , llm-tool-runtime).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T23:05:37.059295Z 9eb4ffc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9eb4ffc4b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +476 to +480
.map(|rec| SearchResult {
content: rec.value,
source: semantic_memory::SearchSource::Fact {
fact_id: rec.id,
namespace: scope.namespace.clone(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enforce scope before returning injected bitemporal records

When a runtime has injected records, querying another namespace or a narrower workspace/repository scope returns the same records: as_of receives only timestamps, and the mapping simply labels every returned record with the requested namespace. This bypasses the scope filtering performed by the projection adapter and can expose records outside the requested scope, even when projection-backed execution enforced that scope successfully. Associate injected records with their originating scope and filter them before returning results; do not relabel unscoped records as belonging to the caller's namespace. The crate's scoped guidance explicitly requires scope pushdown and disclosure of widening.

AGENTS.md reference: knowledge-runtime/AGENTS.md:L23-L25

Useful? React with 👍 / 👎.

Comment on lines +473 to +476
if !asof.is_empty() {
results = asof
.into_iter()
.map(|rec| SearchResult {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Apply query selection and result limits to the temporal source

Whenever any injected records are visible at the requested timestamps, this replaces the query pipeline's results with every visible record, regardless of the query text, resolved entity, or configured result limit. For example, a targeted temporal query with default_limit = 10 can return hundreds of unrelated records while discarding matching projection results. Integrate the temporal source into retrieval and merge rather than substituting a full snapshot after merging. This also violates the crate-specific requirement to preserve projection-backed retrieval as the supported substrate.

AGENTS.md reference: knowledge-runtime/AGENTS.md:L23-L24

Useful? React with 👍 / 👎.

Comment on lines +74 to +78
.map(|r| ToolObservationMemoryRecordV1 {
tool_name: String::new(),
invocation_id: String::new(),
session_id: None,
scope: scope.to_string(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore observation fields from persisted metadata

Searching for a stored observation always replaces its tool name, invocation ID, status, session, timestamps, and receipt ID with empty values, despite persisting those fields in metadata. Consequently, even a successful store/search round trip cannot identify the invocation or dereference its receipt, unlike the existing in-memory implementation, which returns the original record. Resolve each matching fact and deserialize its stored observation metadata instead of constructing a summary-only placeholder.

Useful? React with 👍 / 👎.

Comment on lines +62 to +65
let namespaces = [scope];
let results = self
.search(query, Some(limit), Some(&namespaces), None)
.await

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict observation searches to observation records

If the supplied MemoryStore also contains ordinary facts in the requested namespace, this unrestricted search returns those facts and then converts them into tool observations. The stored kind marker and OBSERVATION_SOURCE are never checked, so unrelated facts can both appear as fabricated observations and consume the result limit ahead of real observations. Filter by the observation source/kind before applying the observation limit.

Useful? React with 👍 / 👎.

Comment on lines +34 to +38
self.add_fact(
&record.scope,
&record.summary,
Some(OBSERVATION_SOURCE),
Some(metadata),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve distinct invocations with identical summaries

When two invocations in the same scope produce the same summary, the second observation is silently discarded. MemoryStore::add_fact_with_trace deduplicates solely by namespace and content and returns the existing fact ID without updating metadata, so different invocation IDs, statuses, or receipt IDs do not make these writes distinct. Use observation identity in the persistence scheme rather than relying on summary-only fact insertion, otherwise repeated tool runs cannot be durably represented.

Useful? React with 👍 / 👎.

Comment on lines +473 to +474
if !asof.is_empty() {
results = asof

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve empty results from the configured temporal source

When injected records exist but none are visible at the requested valid/recorded coordinates, this condition discards the empty as-of answer and retains the earlier pipeline results. With no projection imports and non-strict temporal mode, that pipeline performs ordinary hybrid search, so querying before the first injected version can return current facts instead of the empty historical state. Distinguish an unconfigured source from a configured source with no visible records, and preserve the latter's empty answer rather than treating it as a reason to fall back. The scoped guidance specifically forbids substituting hybrid fact search for temporal behavior.

AGENTS.md reference: knowledge-runtime/AGENTS.md:L38-L39

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant